package com.itheima.controller;

import com.itheima.Service.BookService;
import com.itheima.pojo.Book;
import com.itheima.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/books")
public class BookController {

    @Autowired
    private BookService bookService;

    @GetMapping
    public List<Book> findAll(){
        List<Book> list = bookService.selectAll();
        return list;
    }

    //2.新增 Post
    @PostMapping
    public Result addBook(@RequestBody Book book) throws IOException {
        return new Result(1,  "添加成功");
    }
}
